<?php

namespace App\Http\Middleware;

use Closure;

class Sitebar
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $this->bibel();
        return $next($request);
    }

    //思考, 源自Holy Bible
    private function bibel()
    {
        @$bibels = file('bibel.txt');
        $size = count($bibels) / 2 - 1;
        $rand = rand(0, $size) * 2;
        $bibel = array(
            'cn' => $bibels[$rand + 1],
            'en' => $bibels[$rand]
        );

        view()->share(['bibel' => $bibel]);
    }
}
